﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MedicViet.Models;

namespace MedicViet.Controllers
{
    public class CacDonViHopTacController : Controller
    {
        private MedicVietEntities db = new MedicVietEntities();

        //
        // GET: /TinTucYHoc/

        public ViewResult Index()
        {
            var about = (from c in db.mvCategories.Where(cat => cat.name == "CacDonViHopTac")
                         from p in db.mvNews.Where(news => news.mvCategories.Contains(c))
                         orderby p.dateCreate
                         descending
                         select p).ToList<mvNew>();
            return View(about);
        }

        //
        // GET: /TinTucYHoc/Details/5

        public ViewResult Details(int id)
        {
            mvNew mvnew = db.mvNews.Single(m => m.id == id);
            return View(mvnew);
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}